package com.gzm.user.books.controller;

import com.gzm.user.books.entity.Book;
import com.gzm.user.books.service.BookService;
import com.gzm.framework.aop.annotation.Limit;
import com.gzm.framework.aop.enums.LimitType;
import com.gzm.framework.common.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author GZM
 * @since 2021-12-19
 */
@RestController
@RequestMapping("/user/book")
public class BookController {

    @Autowired
    private BookService bookService;

    /**
     * 根据id获取书籍
     * @return 书籍信息
     */
    @GetMapping
    @Limit(name = "获取书籍", period = 30, count = 1, limitType = LimitType.IP)
    public CommonResult<Book> getbook(){
        return CommonResult.success(bookService.getById(1));
    }

}
